package com.esri.core.map;

import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MapGeometry;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.a;
import com.esri.core.internal.util.g;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.MappingJsonFactory;

/* loaded from: classes.dex */
public class MosaicRule implements Serializable {
    private static final String A = "esriMosaicNorthwest";
    private static final String B = "esriMosaicSeamline";
    private static final String C = "esriMosaicViewpoint";
    private static final String D = "MT_BLEND";
    private static final String E = "MT_FIRST";
    private static final String F = "MT_LAST";
    private static final String G = "MT_MAX";
    private static final String H = "MT_MEAN";
    private static final String I = "MT_MIN";
    private static final String J = "MT_SUM";
    public static final int METHOD_ATTRIBUTE = 1;
    public static final int METHOD_CENTER = 2;
    public static final int METHOD_LOCKRASTER = 3;
    public static final int METHOD_NADIR = 4;
    public static final int METHOD_NONE = 0;
    public static final int METHOD_NORTHWEST = 5;
    public static final int METHOD_SEAMLINE = 6;
    public static final int METHOD_VIEWPOINT = 7;
    public static final int OPERATION_BLEND = 1;
    public static final int OPERATION_FIRST = 2;
    public static final int OPERATION_LAST = 3;
    public static final int OPERATION_MAX = 4;
    public static final int OPERATION_MEAN = 5;
    public static final int OPERATION_MIN = 6;
    public static final int OPERATION_SUM = 7;
    private static final String l = "mosaicMethod";
    private static final String m = "where";
    private static final String n = "sortField";
    private static final String o = "sortValue";
    private static final String p = "ascending";
    private static final String q = "lockRasterIds";
    private static final String r = "viewpoint";
    private static final String s = "fids";
    private static final long serialVersionUID = 1;
    private static final String t = "mosaicOperation";
    private static final String u = "itemRenderingRule";
    private static final String v = "esriMosaicAttribute";
    private static final String w = "esriMosaicCenter";
    private static final String x = "esriMosaicLockRaster";
    private static final String y = "esriMosaicNadir";
    private static final String z = "esriMosaicNone";
    boolean a;
    int[] b;
    int c;
    int[] d;
    int e;
    String f;
    String g;
    Point h;
    String i;
    SpatialReference j;
    RasterFunction k;

    public MosaicRule() {
        this.c = -1;
        this.e = -1;
    }

    public MosaicRule(MosaicRule mosaicRule) {
        this.c = -1;
        this.e = -1;
        if (mosaicRule != null) {
            this.a = mosaicRule.a;
            int[] iArr = mosaicRule.b;
            if (iArr != null) {
                int[] iArr2 = new int[iArr.length];
                this.b = iArr2;
                System.arraycopy(mosaicRule.b, 0, iArr2, 0, iArr2.length);
            } else {
                this.b = null;
            }
            this.c = mosaicRule.c;
            int[] iArr3 = mosaicRule.d;
            if (iArr3 != null) {
                int[] iArr4 = new int[iArr3.length];
                this.d = iArr4;
                System.arraycopy(mosaicRule.d, 0, iArr4, 0, iArr4.length);
            } else {
                this.d = null;
            }
            this.e = mosaicRule.e;
            this.f = mosaicRule.f;
            this.g = mosaicRule.g;
            Point point = mosaicRule.h;
            if (point != null && !point.isEmpty()) {
                this.h = (Point) mosaicRule.h.copy();
            } else {
                this.h = null;
            }
            this.i = mosaicRule.i;
            this.j = mosaicRule.j;
            if (mosaicRule.k != null) {
                this.k = new RasterFunction(this.k);
            }
        }
    }

    public boolean isAscending() {
        return this.a;
    }

    public void setAscending(boolean z2) {
        this.a = z2;
    }

    public int[] getLockRasterIds() {
        return this.b;
    }

    public void setLockRasterIds(int[] iArr) {
        this.b = iArr;
    }

    public int getMethod() {
        return this.c;
    }

    public void setMethod(int i) {
        this.c = i;
    }

    public int[] getObjectIds() {
        return this.d;
    }

    public void setObjectIds(int[] iArr) {
        this.d = iArr;
    }

    public int getOperation() {
        return this.e;
    }

    public void setOperation(int i) {
        this.e = i;
    }

    public String getSortField() {
        return this.f;
    }

    public void setSortField(String str) {
        this.f = str;
    }

    public String getSortValue() {
        return this.g;
    }

    public void setSortValue(String str) {
        this.g = str;
    }

    public Point getViewpoint() {
        return this.h;
    }

    public void setViewpoint(Point point) {
        this.h = point;
    }

    public String getWhere() {
        return this.i;
    }

    public SpatialReference getViewpointSpatialReference() {
        return this.j;
    }

    public void setViewpointSpatialReference(SpatialReference spatialReference) {
        this.j = spatialReference;
    }

    public void setWhere(String str) {
        this.i = str;
    }

    public RasterFunction getItemRenderingRule() {
        return this.k;
    }

    public void setItemRenderingRule(RasterFunction rasterFunction) {
        this.k = rasterFunction;
    }

    public static MosaicRule fromJson(JsonParser jsonParser) throws JsonParseException, IOException {
        if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
            return null;
        }
        MosaicRule mosaicRule = new MosaicRule();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if (l.equals(currentName)) {
                mosaicRule.c = a(jsonParser.getText());
            } else if (m.equals(currentName)) {
                mosaicRule.i = jsonParser.getText();
            } else if (n.equals(currentName)) {
                mosaicRule.f = jsonParser.getText();
            } else if (o.equals(currentName)) {
                mosaicRule.g = jsonParser.getText();
            } else if (p.equals(currentName)) {
                mosaicRule.a = jsonParser.getBooleanValue();
            } else if (q.equals(currentName)) {
                ArrayList arrayList = new ArrayList();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    arrayList.add(Integer.valueOf(jsonParser.getIntValue()));
                }
                mosaicRule.b = a.a(arrayList);
            } else if (r.equals(currentName)) {
                MapGeometry jsonToGeometry = GeometryEngine.jsonToGeometry(jsonParser);
                if (jsonToGeometry != null && (jsonToGeometry.getGeometry() instanceof Point)) {
                    mosaicRule.h = (Point) jsonToGeometry.getGeometry();
                }
            } else if (s.equals(currentName)) {
                ArrayList arrayList2 = new ArrayList();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    arrayList2.add(Integer.valueOf(jsonParser.getIntValue()));
                }
                mosaicRule.d = a.a(arrayList2);
            } else if (t.equals(currentName)) {
                mosaicRule.e = b(jsonParser.getText());
            } else if (u.equals(currentName)) {
                mosaicRule.k = RasterFunction.fromJson(jsonParser);
            }
        }
        return mosaicRule;
    }

    public String toJson() throws JsonGenerationException, IOException {
        int[] iArr;
        StringWriter stringWriter = new StringWriter();
        JsonGenerator createJsonGenerator = new MappingJsonFactory().createJsonGenerator(stringWriter);
        createJsonGenerator.writeStartObject();
        int i = this.c;
        if (i >= 0) {
            switch (i) {
                case 0:
                    createJsonGenerator.writeStringField(l, z);
                    break;
                case 1:
                    createJsonGenerator.writeStringField(l, v);
                    break;
                case 2:
                    createJsonGenerator.writeStringField(l, w);
                    break;
                case 3:
                    createJsonGenerator.writeStringField(l, x);
                    break;
                case 4:
                    createJsonGenerator.writeStringField(l, y);
                    break;
                case 5:
                    createJsonGenerator.writeStringField(l, A);
                    break;
                case 6:
                    createJsonGenerator.writeStringField(l, B);
                    break;
                case 7:
                    createJsonGenerator.writeStringField(l, C);
                    break;
            }
        }
        if (g.b(this.i)) {
            createJsonGenerator.writeStringField(m, this.i);
        }
        if (g.b(this.f)) {
            createJsonGenerator.writeStringField(n, this.f);
        }
        String str = this.g;
        if (str != null) {
            createJsonGenerator.writeStringField(o, str);
        }
        createJsonGenerator.writeBooleanField(p, this.a);
        int[] iArr2 = this.b;
        if (iArr2 != null && iArr2.length > 0) {
            createJsonGenerator.writeObjectField(q, iArr2);
        }
        if (this.d != null) {
            StringBuilder sb = new StringBuilder();
            sb.append('[');
            boolean z2 = true;
            for (int i2 : this.d) {
                if (z2) {
                    z2 = false;
                } else {
                    sb.append(',');
                }
                sb.append(i2);
            }
            sb.append(']');
            createJsonGenerator.writeStringField(s, sb.toString());
        }
        Point point = this.h;
        if (point != null && !point.isEmpty()) {
            createJsonGenerator.writeFieldName(r);
            createJsonGenerator.writeRawValue(GeometryEngine.geometryToJson(this.j, this.h));
        }
        int i3 = this.e;
        if (i3 >= 0) {
            switch (i3) {
                case 1:
                    createJsonGenerator.writeStringField(t, D);
                    break;
                case 2:
                    createJsonGenerator.writeStringField(t, E);
                    break;
                case 3:
                    createJsonGenerator.writeStringField(t, F);
                    break;
                case 4:
                    createJsonGenerator.writeStringField(t, G);
                    break;
                case 5:
                    createJsonGenerator.writeStringField(t, H);
                    break;
                case 6:
                    createJsonGenerator.writeStringField(t, I);
                    break;
                case 7:
                    createJsonGenerator.writeStringField(t, J);
                    break;
            }
        }
        if (this.k != null) {
            createJsonGenerator.writeFieldName(u);
            createJsonGenerator.writeRawValue(this.k.toJson());
        }
        createJsonGenerator.writeEndObject();
        createJsonGenerator.close();
        return stringWriter.getBuffer().toString();
    }

    public int hashCode() {
        int hashCode = ((((((((((this.a ? 1231 : 1237) + 31) * 31) + Arrays.hashCode(this.b)) * 31) + this.c) * 31) + Arrays.hashCode(this.d)) * 31) + this.e) * 31;
        String str = this.f;
        int hashCode2 = (hashCode + (str == null ? 0 : str.hashCode())) * 31;
        String str2 = this.g;
        int hashCode3 = (hashCode2 + (str2 == null ? 0 : str2.hashCode())) * 31;
        Point point = this.h;
        int hashCode4 = (hashCode3 + (point == null ? 0 : point.hashCode())) * 31;
        SpatialReference spatialReference = this.j;
        int hashCode5 = (hashCode4 + (spatialReference == null ? 0 : spatialReference.hashCode())) * 31;
        String str3 = this.i;
        int hashCode6 = (hashCode5 + (str3 == null ? 0 : str3.hashCode())) * 31;
        RasterFunction rasterFunction = this.k;
        return hashCode6 + (rasterFunction != null ? rasterFunction.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        RasterFunction rasterFunction;
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            MosaicRule mosaicRule = (MosaicRule) obj;
            if (this.a == mosaicRule.a && Arrays.equals(this.b, mosaicRule.b) && this.c == mosaicRule.c && Arrays.equals(this.d, mosaicRule.d) && this.e == mosaicRule.e) {
                String str = this.f;
                if (str == null) {
                    if (mosaicRule.f != null) {
                        return false;
                    }
                } else if (!str.equals(mosaicRule.f)) {
                    return false;
                }
                String str2 = this.g;
                if (str2 == null) {
                    if (mosaicRule.g != null) {
                        return false;
                    }
                } else if (!str2.equals(mosaicRule.g)) {
                    return false;
                }
                Point point = this.h;
                if (point == null) {
                    if (mosaicRule.h != null) {
                        return false;
                    }
                } else if (!point.equals(mosaicRule.h)) {
                    return false;
                }
                SpatialReference spatialReference = this.j;
                if (spatialReference == null) {
                    if (mosaicRule.j != null) {
                        return false;
                    }
                } else if (!spatialReference.equals(mosaicRule.j)) {
                    return false;
                }
                String str3 = this.i;
                if (str3 == null) {
                    if (mosaicRule.i != null) {
                        return false;
                    }
                } else if (!str3.equals(mosaicRule.i)) {
                    return false;
                }
                RasterFunction rasterFunction2 = this.k;
                return rasterFunction2 != null || ((rasterFunction = mosaicRule.k) == null && rasterFunction2.equals(rasterFunction));
            }
            return false;
        }
        return false;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("MosaicRule [ascending=");
        sb.append(this.a);
        sb.append(", lockRasterIds=");
        int[] iArr = this.b;
        sb.append(iArr != null ? Arrays.toString(Arrays.copyOf(iArr, Math.min(iArr.length, 3))) : null);
        sb.append(", method=");
        sb.append(this.c);
        sb.append(", objectIds=");
        int[] iArr2 = this.d;
        sb.append(iArr2 != null ? Arrays.toString(Arrays.copyOf(iArr2, Math.min(iArr2.length, 3))) : null);
        sb.append(", operation=");
        sb.append(this.e);
        sb.append(", sortField=");
        sb.append(this.f);
        sb.append(", sortValue=");
        sb.append(this.g);
        sb.append(", viewpoint=");
        sb.append(this.h);
        sb.append(", where=");
        sb.append(this.i);
        sb.append(", viewpointSpatialReference=");
        sb.append(this.j);
        sb.append("]");
        return sb.toString();
    }

    private static int a(String str) {
        if (g.b(str)) {
            if (str.equals(v)) {
                return 1;
            }
            if (str.equals(w)) {
                return 2;
            }
            if (str.equals(z)) {
                return 0;
            }
            if (str.equals(x)) {
                return 3;
            }
            if (str.equals(y)) {
                return 4;
            }
            if (str.equals(A)) {
                return 5;
            }
            if (str.equals(B)) {
                return 6;
            }
            if (str.equals(C)) {
                return 7;
            }
        }
        return -1;
    }

    private static int b(String str) {
        if (g.b(str)) {
            if (str.equals(E)) {
                return 2;
            }
            if (str.equals(F)) {
                return 3;
            }
            if (str.equals(D)) {
                return 1;
            }
            if (str.equals(G)) {
                return 4;
            }
            if (str.equals(H)) {
                return 5;
            }
            if (str.equals(I)) {
                return 6;
            }
            if (str.equals(J)) {
                return 7;
            }
        }
        return -1;
    }
}
